package com.lsh.bio;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author ：LiuShihao
 * @date ：Created in 2021/2/23 12:40 下午
 * @desc ：伪异步IO编程  创建一个IO任务线程池
 */
public class TimeServerHandlerExecutePool {

    private ExecutorService executor;
    //创建一个线程池
    public TimeServerHandlerExecutePool(int maxPollSize, int queueSize) {
        executor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
                maxPollSize,120L, TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(queueSize));
    }
    //执行
    public void execute(Runnable task) {
        executor.execute(task);
    }
}
